//
//  main.cpp
//  opencv_project
//
//  Created by 黄琛 on 2018/12/30.
//  Copyright © 2018 黄琛. All rights reserved.
//

#include "opencv2/opencv.hpp"
#include "opencv2/xfeatures2d.hpp"

using namespace cv;
using namespace std;

int main(void)
{
    Mat src = imread("left03.jpg");
    Mat src1,src2,src3;
    pyrDown(src, src);
    src1 = src.clone();
    src2 = src.clone();
    src3 = src.clone();
    
    //Fast算法实现
    vector<KeyPoint>keypoints1;
    Ptr<FeatureDetector> fast = FastFeatureDetector::create(40);
    fast->detect(src, keypoints1);
    drawKeypoints(src, keypoints1, src, Scalar(0,0,255), DrawMatchesFlags::DRAW_OVER_OUTIMG);
    
    //SURF算法实现
    vector<KeyPoint>keypoints2;
    Ptr<xfeatures2d::SURF> surf = xfeatures2d::SURF::create(2500);
    surf->detect(src1, keypoints2);
    drawKeypoints(src1, keypoints2, src1, Scalar(0,0,255), DrawMatchesFlags::DRAW_OVER_OUTIMG);
    
    //ORB算法实现
    vector<KeyPoint>keypoints3;
    Ptr<ORB> orb = ORB::create(50);
    orb->detect(src2, keypoints3);
    drawKeypoints(src2, keypoints3, src2, Scalar(0,0,255), DrawMatchesFlags::DRAW_OVER_OUTIMG);
    
    //SIFT算法实现
    vector<KeyPoint>keypoints4;
    Ptr<xfeatures2d::SIFT> sift = xfeatures2d::SIFT::create(50);
    sift->detect(src3, keypoints4);
    drawKeypoints(src3, keypoints4, src3, Scalar(0,0,255), DrawMatchesFlags::DRAW_OVER_OUTIMG);

    imshow("result of FAST", src);
    imshow("result of SURF", src1);
    imshow("result of ORB", src2);
    imshow("result of SIFT", src3);
    
    waitKey(0);
    
    return 0;
}
